<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>

    <script>

        // 

        var date = new Date('2022-10-1') ;

        djs(date) ;


        function djs(d2) {
            var d1 = new Date();
            

            // 时间可以减法
            var gap = parseInt((d2 - d1) / 1000);
            console.log(gap);


            var t = setInterval(function () {
                gap--;
                console.log(gap);
                // 转化时分秒


                if (gap === 0) {
                    clearInterval(t)
                }
            }, 1000)
        }

    </script>

</body>

</html>